// $ANTLR 3.2 Sep 23, 2009 12:02:23 /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g 2010-01-25 14:32:04

package com.googlecode.bestpaper;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class BestpaperParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "BOOK", "CHAPTER", "CHAPTER_HEADING", "SECTION", "PARAGRAPH", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "LEVEL6", "ROW", "NEWLINE", "SPACE", "CH", "H1", "H2", "H3", "H4", "H5", "H6", "WORD", "TABLE_BORD"
    };
    public static final int LEVEL4=12;
    public static final int LEVEL5=13;
    public static final int LEVEL6=14;
    public static final int SECTION=7;
    public static final int ROW=15;
    public static final int CHAPTER_HEADING=6;
    public static final int BOOK=4;
    public static final int CHAPTER=5;
    public static final int TABLE_BORD=26;
    public static final int LEVEL1=9;
    public static final int EOF=-1;
    public static final int SPACE=17;
    public static final int LEVEL3=11;
    public static final int LEVEL2=10;
    public static final int WORD=25;
    public static final int NEWLINE=16;
    public static final int PARAGRAPH=8;
    public static final int H6=24;
    public static final int H5=23;
    public static final int H4=22;
    public static final int CH=18;
    public static final int H3=21;
    public static final int H2=20;
    public static final int H1=19;

    // delegates
    // delegators


        public BestpaperParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public BestpaperParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return BestpaperParser.tokenNames; }
    public String getGrammarFileName() { return "/Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g"; }


    public static class book_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "book"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:23:1: book : ( chapter ( NEWLINE )+ )* chapter ( NEWLINE )* -> ^( BOOK ( chapter )+ ) ;
    public final BestpaperParser.book_return book() throws RecognitionException {
        BestpaperParser.book_return retval = new BestpaperParser.book_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NEWLINE2=null;
        Token NEWLINE4=null;
        BestpaperParser.chapter_return chapter1 = null;

        BestpaperParser.chapter_return chapter3 = null;


        CommonTree NEWLINE2_tree=null;
        CommonTree NEWLINE4_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_chapter=new RewriteRuleSubtreeStream(adaptor,"rule chapter");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:2: ( ( chapter ( NEWLINE )+ )* chapter ( NEWLINE )* -> ^( BOOK ( chapter )+ ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:4: ( chapter ( NEWLINE )+ )* chapter ( NEWLINE )*
            {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:4: ( chapter ( NEWLINE )+ )*
            loop2:
            do {
                int alt2=2;
                alt2 = dfa2.predict(input);
                switch (alt2) {
            	case 1 :
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:5: chapter ( NEWLINE )+
            	    {
            	    pushFollow(FOLLOW_chapter_in_book99);
            	    chapter1=chapter();

            	    state._fsp--;

            	    stream_chapter.add(chapter1.getTree());
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:13: ( NEWLINE )+
            	    int cnt1=0;
            	    loop1:
            	    do {
            	        int alt1=2;
            	        int LA1_0 = input.LA(1);

            	        if ( (LA1_0==NEWLINE) ) {
            	            alt1=1;
            	        }


            	        switch (alt1) {
            	    	case 1 :
            	    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:13: NEWLINE
            	    	    {
            	    	    NEWLINE2=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_book101);  
            	    	    stream_NEWLINE.add(NEWLINE2);


            	    	    }
            	    	    break;

            	    	default :
            	    	    if ( cnt1 >= 1 ) break loop1;
            	                EarlyExitException eee =
            	                    new EarlyExitException(1, input);
            	                throw eee;
            	        }
            	        cnt1++;
            	    } while (true);


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            pushFollow(FOLLOW_chapter_in_book106);
            chapter3=chapter();

            state._fsp--;

            stream_chapter.add(chapter3.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:32: ( NEWLINE )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==NEWLINE) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:32: NEWLINE
            	    {
            	    NEWLINE4=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_book108);  
            	    stream_NEWLINE.add(NEWLINE4);


            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);



            // AST REWRITE
            // elements: chapter
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 24:41: -> ^( BOOK ( chapter )+ )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:24:44: ^( BOOK ( chapter )+ )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(BOOK, "BOOK"), root_1);

                if ( !(stream_chapter.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_chapter.hasNext() ) {
                    adaptor.addChild(root_1, stream_chapter.nextTree());

                }
                stream_chapter.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "book"

    public static class chapter_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "chapter"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:25:1: chapter : ( chapter_heading ( NEWLINE )+ ( content ( NEWLINE )+ )? ( section ( NEWLINE )+ )* section -> ^( CHAPTER chapter_heading ( content )? ( section )+ ) | chapter_heading ( NEWLINE )+ content -> ^( CHAPTER chapter_heading content ) );
    public final BestpaperParser.chapter_return chapter() throws RecognitionException {
        BestpaperParser.chapter_return retval = new BestpaperParser.chapter_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NEWLINE6=null;
        Token NEWLINE8=null;
        Token NEWLINE10=null;
        Token NEWLINE13=null;
        BestpaperParser.chapter_heading_return chapter_heading5 = null;

        BestpaperParser.content_return content7 = null;

        BestpaperParser.section_return section9 = null;

        BestpaperParser.section_return section11 = null;

        BestpaperParser.chapter_heading_return chapter_heading12 = null;

        BestpaperParser.content_return content14 = null;


        CommonTree NEWLINE6_tree=null;
        CommonTree NEWLINE8_tree=null;
        CommonTree NEWLINE10_tree=null;
        CommonTree NEWLINE13_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_content=new RewriteRuleSubtreeStream(adaptor,"rule content");
        RewriteRuleSubtreeStream stream_chapter_heading=new RewriteRuleSubtreeStream(adaptor,"rule chapter_heading");
        RewriteRuleSubtreeStream stream_section=new RewriteRuleSubtreeStream(adaptor,"rule section");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:2: ( chapter_heading ( NEWLINE )+ ( content ( NEWLINE )+ )? ( section ( NEWLINE )+ )* section -> ^( CHAPTER chapter_heading ( content )? ( section )+ ) | chapter_heading ( NEWLINE )+ content -> ^( CHAPTER chapter_heading content ) )
            int alt10=2;
            alt10 = dfa10.predict(input);
            switch (alt10) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:4: chapter_heading ( NEWLINE )+ ( content ( NEWLINE )+ )? ( section ( NEWLINE )+ )* section
                    {
                    pushFollow(FOLLOW_chapter_heading_in_chapter129);
                    chapter_heading5=chapter_heading();

                    state._fsp--;

                    stream_chapter_heading.add(chapter_heading5.getTree());
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:20: ( NEWLINE )+
                    int cnt4=0;
                    loop4:
                    do {
                        int alt4=2;
                        int LA4_0 = input.LA(1);

                        if ( (LA4_0==NEWLINE) ) {
                            alt4=1;
                        }


                        switch (alt4) {
                    	case 1 :
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:20: NEWLINE
                    	    {
                    	    NEWLINE6=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_chapter131);  
                    	    stream_NEWLINE.add(NEWLINE6);


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt4 >= 1 ) break loop4;
                                EarlyExitException eee =
                                    new EarlyExitException(4, input);
                                throw eee;
                        }
                        cnt4++;
                    } while (true);

                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:29: ( content ( NEWLINE )+ )?
                    int alt6=2;
                    int LA6_0 = input.LA(1);

                    if ( (LA6_0==SPACE) ) {
                        int LA6_1 = input.LA(2);

                        if ( (LA6_1==NEWLINE||(LA6_1>=WORD && LA6_1<=TABLE_BORD)) ) {
                            alt6=1;
                        }
                    }
                    else if ( ((LA6_0>=WORD && LA6_0<=TABLE_BORD)) ) {
                        alt6=1;
                    }
                    switch (alt6) {
                        case 1 :
                            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:30: content ( NEWLINE )+
                            {
                            pushFollow(FOLLOW_content_in_chapter135);
                            content7=content();

                            state._fsp--;

                            stream_content.add(content7.getTree());
                            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:38: ( NEWLINE )+
                            int cnt5=0;
                            loop5:
                            do {
                                int alt5=2;
                                int LA5_0 = input.LA(1);

                                if ( (LA5_0==NEWLINE) ) {
                                    alt5=1;
                                }


                                switch (alt5) {
                            	case 1 :
                            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:38: NEWLINE
                            	    {
                            	    NEWLINE8=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_chapter137);  
                            	    stream_NEWLINE.add(NEWLINE8);


                            	    }
                            	    break;

                            	default :
                            	    if ( cnt5 >= 1 ) break loop5;
                                        EarlyExitException eee =
                                            new EarlyExitException(5, input);
                                        throw eee;
                                }
                                cnt5++;
                            } while (true);


                            }
                            break;

                    }

                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:49: ( section ( NEWLINE )+ )*
                    loop8:
                    do {
                        int alt8=2;
                        alt8 = dfa8.predict(input);
                        switch (alt8) {
                    	case 1 :
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:50: section ( NEWLINE )+
                    	    {
                    	    pushFollow(FOLLOW_section_in_chapter143);
                    	    section9=section();

                    	    state._fsp--;

                    	    stream_section.add(section9.getTree());
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:58: ( NEWLINE )+
                    	    int cnt7=0;
                    	    loop7:
                    	    do {
                    	        int alt7=2;
                    	        int LA7_0 = input.LA(1);

                    	        if ( (LA7_0==NEWLINE) ) {
                    	            alt7=1;
                    	        }


                    	        switch (alt7) {
                    	    	case 1 :
                    	    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:58: NEWLINE
                    	    	    {
                    	    	    NEWLINE10=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_chapter145);  
                    	    	    stream_NEWLINE.add(NEWLINE10);


                    	    	    }
                    	    	    break;

                    	    	default :
                    	    	    if ( cnt7 >= 1 ) break loop7;
                    	                EarlyExitException eee =
                    	                    new EarlyExitException(7, input);
                    	                throw eee;
                    	        }
                    	        cnt7++;
                    	    } while (true);


                    	    }
                    	    break;

                    	default :
                    	    break loop8;
                        }
                    } while (true);

                    pushFollow(FOLLOW_section_in_chapter150);
                    section11=section();

                    state._fsp--;

                    stream_section.add(section11.getTree());


                    // AST REWRITE
                    // elements: chapter_heading, section, content
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 26:77: -> ^( CHAPTER chapter_heading ( content )? ( section )+ )
                    {
                        // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:80: ^( CHAPTER chapter_heading ( content )? ( section )+ )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(CHAPTER, "CHAPTER"), root_1);

                        adaptor.addChild(root_1, stream_chapter_heading.nextTree());
                        // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:26:106: ( content )?
                        if ( stream_content.hasNext() ) {
                            adaptor.addChild(root_1, stream_content.nextTree());

                        }
                        stream_content.reset();
                        if ( !(stream_section.hasNext()) ) {
                            throw new RewriteEarlyExitException();
                        }
                        while ( stream_section.hasNext() ) {
                            adaptor.addChild(root_1, stream_section.nextTree());

                        }
                        stream_section.reset();

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:27:4: chapter_heading ( NEWLINE )+ content
                    {
                    pushFollow(FOLLOW_chapter_heading_in_chapter169);
                    chapter_heading12=chapter_heading();

                    state._fsp--;

                    stream_chapter_heading.add(chapter_heading12.getTree());
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:27:20: ( NEWLINE )+
                    int cnt9=0;
                    loop9:
                    do {
                        int alt9=2;
                        int LA9_0 = input.LA(1);

                        if ( (LA9_0==NEWLINE) ) {
                            alt9=1;
                        }


                        switch (alt9) {
                    	case 1 :
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:27:20: NEWLINE
                    	    {
                    	    NEWLINE13=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_chapter171);  
                    	    stream_NEWLINE.add(NEWLINE13);


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt9 >= 1 ) break loop9;
                                EarlyExitException eee =
                                    new EarlyExitException(9, input);
                                throw eee;
                        }
                        cnt9++;
                    } while (true);

                    pushFollow(FOLLOW_content_in_chapter174);
                    content14=content();

                    state._fsp--;

                    stream_content.add(content14.getTree());


                    // AST REWRITE
                    // elements: chapter_heading, content
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 27:37: -> ^( CHAPTER chapter_heading content )
                    {
                        // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:27:40: ^( CHAPTER chapter_heading content )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(CHAPTER, "CHAPTER"), root_1);

                        adaptor.addChild(root_1, stream_chapter_heading.nextTree());
                        adaptor.addChild(root_1, stream_content.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "chapter"

    public static class chapter_heading_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "chapter_heading"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:29:1: chapter_heading : ( SPACE )? CH ( SPACE )? title ( SPACE )? CH ( SPACE )? -> ^( CHAPTER_HEADING title ) ;
    public final BestpaperParser.chapter_heading_return chapter_heading() throws RecognitionException {
        BestpaperParser.chapter_heading_return retval = new BestpaperParser.chapter_heading_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token SPACE15=null;
        Token CH16=null;
        Token SPACE17=null;
        Token SPACE19=null;
        Token CH20=null;
        Token SPACE21=null;
        BestpaperParser.title_return title18 = null;


        CommonTree SPACE15_tree=null;
        CommonTree CH16_tree=null;
        CommonTree SPACE17_tree=null;
        CommonTree SPACE19_tree=null;
        CommonTree CH20_tree=null;
        CommonTree SPACE21_tree=null;
        RewriteRuleTokenStream stream_CH=new RewriteRuleTokenStream(adaptor,"token CH");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:2: ( ( SPACE )? CH ( SPACE )? title ( SPACE )? CH ( SPACE )? -> ^( CHAPTER_HEADING title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:4: ( SPACE )? CH ( SPACE )? title ( SPACE )? CH ( SPACE )?
            {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:4: ( SPACE )?
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0==SPACE) ) {
                alt11=1;
            }
            switch (alt11) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:4: SPACE
                    {
                    SPACE15=(Token)match(input,SPACE,FOLLOW_SPACE_in_chapter_heading199);  
                    stream_SPACE.add(SPACE15);


                    }
                    break;

            }

            CH16=(Token)match(input,CH,FOLLOW_CH_in_chapter_heading202);  
            stream_CH.add(CH16);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:14: ( SPACE )?
            int alt12=2;
            int LA12_0 = input.LA(1);

            if ( (LA12_0==SPACE) ) {
                alt12=1;
            }
            switch (alt12) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:14: SPACE
                    {
                    SPACE17=(Token)match(input,SPACE,FOLLOW_SPACE_in_chapter_heading204);  
                    stream_SPACE.add(SPACE17);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_chapter_heading207);
            title18=title();

            state._fsp--;

            stream_title.add(title18.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:27: ( SPACE )?
            int alt13=2;
            int LA13_0 = input.LA(1);

            if ( (LA13_0==SPACE) ) {
                alt13=1;
            }
            switch (alt13) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:27: SPACE
                    {
                    SPACE19=(Token)match(input,SPACE,FOLLOW_SPACE_in_chapter_heading209);  
                    stream_SPACE.add(SPACE19);


                    }
                    break;

            }

            CH20=(Token)match(input,CH,FOLLOW_CH_in_chapter_heading212);  
            stream_CH.add(CH20);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:37: ( SPACE )?
            int alt14=2;
            int LA14_0 = input.LA(1);

            if ( (LA14_0==SPACE) ) {
                alt14=1;
            }
            switch (alt14) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:37: SPACE
                    {
                    SPACE21=(Token)match(input,SPACE,FOLLOW_SPACE_in_chapter_heading214);  
                    stream_SPACE.add(SPACE21);


                    }
                    break;

            }



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 30:44: -> ^( CHAPTER_HEADING title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:30:47: ^( CHAPTER_HEADING title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(CHAPTER_HEADING, "CHAPTER_HEADING"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "chapter_heading"

    public static class section_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "section"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:31:1: section : ( heading ( NEWLINE )+ content -> ^( SECTION heading content ) | heading -> ^( SECTION heading ) );
    public final BestpaperParser.section_return section() throws RecognitionException {
        BestpaperParser.section_return retval = new BestpaperParser.section_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NEWLINE23=null;
        BestpaperParser.heading_return heading22 = null;

        BestpaperParser.content_return content24 = null;

        BestpaperParser.heading_return heading25 = null;


        CommonTree NEWLINE23_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_content=new RewriteRuleSubtreeStream(adaptor,"rule content");
        RewriteRuleSubtreeStream stream_heading=new RewriteRuleSubtreeStream(adaptor,"rule heading");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:32:2: ( heading ( NEWLINE )+ content -> ^( SECTION heading content ) | heading -> ^( SECTION heading ) )
            int alt16=2;
            alt16 = dfa16.predict(input);
            switch (alt16) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:32:6: heading ( NEWLINE )+ content
                    {
                    pushFollow(FOLLOW_heading_in_section235);
                    heading22=heading();

                    state._fsp--;

                    stream_heading.add(heading22.getTree());
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:32:14: ( NEWLINE )+
                    int cnt15=0;
                    loop15:
                    do {
                        int alt15=2;
                        int LA15_0 = input.LA(1);

                        if ( (LA15_0==NEWLINE) ) {
                            alt15=1;
                        }


                        switch (alt15) {
                    	case 1 :
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:32:14: NEWLINE
                    	    {
                    	    NEWLINE23=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_section237);  
                    	    stream_NEWLINE.add(NEWLINE23);


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt15 >= 1 ) break loop15;
                                EarlyExitException eee =
                                    new EarlyExitException(15, input);
                                throw eee;
                        }
                        cnt15++;
                    } while (true);

                    pushFollow(FOLLOW_content_in_section240);
                    content24=content();

                    state._fsp--;

                    stream_content.add(content24.getTree());


                    // AST REWRITE
                    // elements: heading, content
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 32:31: -> ^( SECTION heading content )
                    {
                        // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:32:34: ^( SECTION heading content )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(SECTION, "SECTION"), root_1);

                        adaptor.addChild(root_1, stream_heading.nextTree());
                        adaptor.addChild(root_1, stream_content.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:33:4: heading
                    {
                    pushFollow(FOLLOW_heading_in_section255);
                    heading25=heading();

                    state._fsp--;

                    stream_heading.add(heading25.getTree());


                    // AST REWRITE
                    // elements: heading
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 33:12: -> ^( SECTION heading )
                    {
                        // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:33:15: ^( SECTION heading )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(SECTION, "SECTION"), root_1);

                        adaptor.addChild(root_1, stream_heading.nextTree());

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "section"

    public static class heading_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:34:1: heading : ( SPACE )? ( heading1 | heading2 | heading3 | heading4 | heading5 | heading6 ) ( SPACE )? ;
    public final BestpaperParser.heading_return heading() throws RecognitionException {
        BestpaperParser.heading_return retval = new BestpaperParser.heading_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token SPACE26=null;
        Token SPACE33=null;
        BestpaperParser.heading1_return heading127 = null;

        BestpaperParser.heading2_return heading228 = null;

        BestpaperParser.heading3_return heading329 = null;

        BestpaperParser.heading4_return heading430 = null;

        BestpaperParser.heading5_return heading531 = null;

        BestpaperParser.heading6_return heading632 = null;


        CommonTree SPACE26_tree=null;
        CommonTree SPACE33_tree=null;

        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:5: ( ( SPACE )? ( heading1 | heading2 | heading3 | heading4 | heading5 | heading6 ) ( SPACE )? )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:7: ( SPACE )? ( heading1 | heading2 | heading3 | heading4 | heading5 | heading6 ) ( SPACE )?
            {
            root_0 = (CommonTree)adaptor.nil();

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:12: ( SPACE )?
            int alt17=2;
            int LA17_0 = input.LA(1);

            if ( (LA17_0==SPACE) ) {
                alt17=1;
            }
            switch (alt17) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:12: SPACE
                    {
                    SPACE26=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading280); 

                    }
                    break;

            }

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:15: ( heading1 | heading2 | heading3 | heading4 | heading5 | heading6 )
            int alt18=6;
            switch ( input.LA(1) ) {
            case H1:
                {
                alt18=1;
                }
                break;
            case H2:
                {
                alt18=2;
                }
                break;
            case H3:
                {
                alt18=3;
                }
                break;
            case H4:
                {
                alt18=4;
                }
                break;
            case H5:
                {
                alt18=5;
                }
                break;
            case H6:
                {
                alt18=6;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 18, 0, input);

                throw nvae;
            }

            switch (alt18) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:16: heading1
                    {
                    pushFollow(FOLLOW_heading1_in_heading285);
                    heading127=heading1();

                    state._fsp--;

                    adaptor.addChild(root_0, heading127.getTree());

                    }
                    break;
                case 2 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:27: heading2
                    {
                    pushFollow(FOLLOW_heading2_in_heading289);
                    heading228=heading2();

                    state._fsp--;

                    adaptor.addChild(root_0, heading228.getTree());

                    }
                    break;
                case 3 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:38: heading3
                    {
                    pushFollow(FOLLOW_heading3_in_heading293);
                    heading329=heading3();

                    state._fsp--;

                    adaptor.addChild(root_0, heading329.getTree());

                    }
                    break;
                case 4 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:49: heading4
                    {
                    pushFollow(FOLLOW_heading4_in_heading297);
                    heading430=heading4();

                    state._fsp--;

                    adaptor.addChild(root_0, heading430.getTree());

                    }
                    break;
                case 5 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:60: heading5
                    {
                    pushFollow(FOLLOW_heading5_in_heading301);
                    heading531=heading5();

                    state._fsp--;

                    adaptor.addChild(root_0, heading531.getTree());

                    }
                    break;
                case 6 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:71: heading6
                    {
                    pushFollow(FOLLOW_heading6_in_heading305);
                    heading632=heading6();

                    state._fsp--;

                    adaptor.addChild(root_0, heading632.getTree());

                    }
                    break;

            }

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:86: ( SPACE )?
            int alt19=2;
            int LA19_0 = input.LA(1);

            if ( (LA19_0==SPACE) ) {
                alt19=1;
            }
            switch (alt19) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:35:86: SPACE
                    {
                    SPACE33=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading308); 

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading"

    public static class heading1_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading1"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:36:1: heading1 : H1 ( SPACE )? title ( SPACE )? H1 -> ^( LEVEL1 title ) ;
    public final BestpaperParser.heading1_return heading1() throws RecognitionException {
        BestpaperParser.heading1_return retval = new BestpaperParser.heading1_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H134=null;
        Token SPACE35=null;
        Token SPACE37=null;
        Token H138=null;
        BestpaperParser.title_return title36 = null;


        CommonTree H134_tree=null;
        CommonTree SPACE35_tree=null;
        CommonTree SPACE37_tree=null;
        CommonTree H138_tree=null;
        RewriteRuleTokenStream stream_H1=new RewriteRuleTokenStream(adaptor,"token H1");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:5: ( H1 ( SPACE )? title ( SPACE )? H1 -> ^( LEVEL1 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:9: H1 ( SPACE )? title ( SPACE )? H1
            {
            H134=(Token)match(input,H1,FOLLOW_H1_in_heading1332);  
            stream_H1.add(H134);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:12: ( SPACE )?
            int alt20=2;
            int LA20_0 = input.LA(1);

            if ( (LA20_0==SPACE) ) {
                alt20=1;
            }
            switch (alt20) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:12: SPACE
                    {
                    SPACE35=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading1334);  
                    stream_SPACE.add(SPACE35);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading1337);
            title36=title();

            state._fsp--;

            stream_title.add(title36.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:25: ( SPACE )?
            int alt21=2;
            int LA21_0 = input.LA(1);

            if ( (LA21_0==SPACE) ) {
                alt21=1;
            }
            switch (alt21) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:25: SPACE
                    {
                    SPACE37=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading1339);  
                    stream_SPACE.add(SPACE37);


                    }
                    break;

            }

            H138=(Token)match(input,H1,FOLLOW_H1_in_heading1342);  
            stream_H1.add(H138);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 37:35: -> ^( LEVEL1 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:37:38: ^( LEVEL1 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL1, "LEVEL1"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading1"

    public static class heading2_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading2"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:38:1: heading2 : H2 ( SPACE )? title ( SPACE )? H2 -> ^( LEVEL2 title ) ;
    public final BestpaperParser.heading2_return heading2() throws RecognitionException {
        BestpaperParser.heading2_return retval = new BestpaperParser.heading2_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H239=null;
        Token SPACE40=null;
        Token SPACE42=null;
        Token H243=null;
        BestpaperParser.title_return title41 = null;


        CommonTree H239_tree=null;
        CommonTree SPACE40_tree=null;
        CommonTree SPACE42_tree=null;
        CommonTree H243_tree=null;
        RewriteRuleTokenStream stream_H2=new RewriteRuleTokenStream(adaptor,"token H2");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:5: ( H2 ( SPACE )? title ( SPACE )? H2 -> ^( LEVEL2 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:9: H2 ( SPACE )? title ( SPACE )? H2
            {
            H239=(Token)match(input,H2,FOLLOW_H2_in_heading2367);  
            stream_H2.add(H239);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:12: ( SPACE )?
            int alt22=2;
            int LA22_0 = input.LA(1);

            if ( (LA22_0==SPACE) ) {
                alt22=1;
            }
            switch (alt22) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:12: SPACE
                    {
                    SPACE40=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading2369);  
                    stream_SPACE.add(SPACE40);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading2372);
            title41=title();

            state._fsp--;

            stream_title.add(title41.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:25: ( SPACE )?
            int alt23=2;
            int LA23_0 = input.LA(1);

            if ( (LA23_0==SPACE) ) {
                alt23=1;
            }
            switch (alt23) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:25: SPACE
                    {
                    SPACE42=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading2374);  
                    stream_SPACE.add(SPACE42);


                    }
                    break;

            }

            H243=(Token)match(input,H2,FOLLOW_H2_in_heading2377);  
            stream_H2.add(H243);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 39:35: -> ^( LEVEL2 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:39:38: ^( LEVEL2 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL2, "LEVEL2"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading2"

    public static class heading3_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading3"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:40:1: heading3 : H3 ( SPACE )? title ( SPACE )? H3 -> ^( LEVEL3 title ) ;
    public final BestpaperParser.heading3_return heading3() throws RecognitionException {
        BestpaperParser.heading3_return retval = new BestpaperParser.heading3_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H344=null;
        Token SPACE45=null;
        Token SPACE47=null;
        Token H348=null;
        BestpaperParser.title_return title46 = null;


        CommonTree H344_tree=null;
        CommonTree SPACE45_tree=null;
        CommonTree SPACE47_tree=null;
        CommonTree H348_tree=null;
        RewriteRuleTokenStream stream_H3=new RewriteRuleTokenStream(adaptor,"token H3");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:5: ( H3 ( SPACE )? title ( SPACE )? H3 -> ^( LEVEL3 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:9: H3 ( SPACE )? title ( SPACE )? H3
            {
            H344=(Token)match(input,H3,FOLLOW_H3_in_heading3402);  
            stream_H3.add(H344);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:12: ( SPACE )?
            int alt24=2;
            int LA24_0 = input.LA(1);

            if ( (LA24_0==SPACE) ) {
                alt24=1;
            }
            switch (alt24) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:12: SPACE
                    {
                    SPACE45=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading3404);  
                    stream_SPACE.add(SPACE45);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading3407);
            title46=title();

            state._fsp--;

            stream_title.add(title46.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:25: ( SPACE )?
            int alt25=2;
            int LA25_0 = input.LA(1);

            if ( (LA25_0==SPACE) ) {
                alt25=1;
            }
            switch (alt25) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:25: SPACE
                    {
                    SPACE47=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading3409);  
                    stream_SPACE.add(SPACE47);


                    }
                    break;

            }

            H348=(Token)match(input,H3,FOLLOW_H3_in_heading3412);  
            stream_H3.add(H348);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 41:35: -> ^( LEVEL3 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:41:38: ^( LEVEL3 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL3, "LEVEL3"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading3"

    public static class heading4_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading4"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:42:1: heading4 : H4 ( SPACE )? title ( SPACE )? H4 -> ^( LEVEL4 title ) ;
    public final BestpaperParser.heading4_return heading4() throws RecognitionException {
        BestpaperParser.heading4_return retval = new BestpaperParser.heading4_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H449=null;
        Token SPACE50=null;
        Token SPACE52=null;
        Token H453=null;
        BestpaperParser.title_return title51 = null;


        CommonTree H449_tree=null;
        CommonTree SPACE50_tree=null;
        CommonTree SPACE52_tree=null;
        CommonTree H453_tree=null;
        RewriteRuleTokenStream stream_H4=new RewriteRuleTokenStream(adaptor,"token H4");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:5: ( H4 ( SPACE )? title ( SPACE )? H4 -> ^( LEVEL4 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:9: H4 ( SPACE )? title ( SPACE )? H4
            {
            H449=(Token)match(input,H4,FOLLOW_H4_in_heading4437);  
            stream_H4.add(H449);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:12: ( SPACE )?
            int alt26=2;
            int LA26_0 = input.LA(1);

            if ( (LA26_0==SPACE) ) {
                alt26=1;
            }
            switch (alt26) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:12: SPACE
                    {
                    SPACE50=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading4439);  
                    stream_SPACE.add(SPACE50);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading4442);
            title51=title();

            state._fsp--;

            stream_title.add(title51.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:25: ( SPACE )?
            int alt27=2;
            int LA27_0 = input.LA(1);

            if ( (LA27_0==SPACE) ) {
                alt27=1;
            }
            switch (alt27) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:25: SPACE
                    {
                    SPACE52=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading4444);  
                    stream_SPACE.add(SPACE52);


                    }
                    break;

            }

            H453=(Token)match(input,H4,FOLLOW_H4_in_heading4447);  
            stream_H4.add(H453);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 43:35: -> ^( LEVEL4 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:43:38: ^( LEVEL4 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL4, "LEVEL4"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading4"

    public static class heading5_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading5"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:44:1: heading5 : H5 ( SPACE )? title ( SPACE )? H5 -> ^( LEVEL5 title ) ;
    public final BestpaperParser.heading5_return heading5() throws RecognitionException {
        BestpaperParser.heading5_return retval = new BestpaperParser.heading5_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H554=null;
        Token SPACE55=null;
        Token SPACE57=null;
        Token H558=null;
        BestpaperParser.title_return title56 = null;


        CommonTree H554_tree=null;
        CommonTree SPACE55_tree=null;
        CommonTree SPACE57_tree=null;
        CommonTree H558_tree=null;
        RewriteRuleTokenStream stream_H5=new RewriteRuleTokenStream(adaptor,"token H5");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:5: ( H5 ( SPACE )? title ( SPACE )? H5 -> ^( LEVEL5 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:9: H5 ( SPACE )? title ( SPACE )? H5
            {
            H554=(Token)match(input,H5,FOLLOW_H5_in_heading5472);  
            stream_H5.add(H554);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:12: ( SPACE )?
            int alt28=2;
            int LA28_0 = input.LA(1);

            if ( (LA28_0==SPACE) ) {
                alt28=1;
            }
            switch (alt28) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:12: SPACE
                    {
                    SPACE55=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading5474);  
                    stream_SPACE.add(SPACE55);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading5477);
            title56=title();

            state._fsp--;

            stream_title.add(title56.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:25: ( SPACE )?
            int alt29=2;
            int LA29_0 = input.LA(1);

            if ( (LA29_0==SPACE) ) {
                alt29=1;
            }
            switch (alt29) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:25: SPACE
                    {
                    SPACE57=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading5479);  
                    stream_SPACE.add(SPACE57);


                    }
                    break;

            }

            H558=(Token)match(input,H5,FOLLOW_H5_in_heading5482);  
            stream_H5.add(H558);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 45:35: -> ^( LEVEL5 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:45:38: ^( LEVEL5 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL5, "LEVEL5"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading5"

    public static class heading6_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "heading6"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:46:1: heading6 : H6 ( SPACE )? title ( SPACE )? H6 -> ^( LEVEL6 title ) ;
    public final BestpaperParser.heading6_return heading6() throws RecognitionException {
        BestpaperParser.heading6_return retval = new BestpaperParser.heading6_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token H659=null;
        Token SPACE60=null;
        Token SPACE62=null;
        Token H663=null;
        BestpaperParser.title_return title61 = null;


        CommonTree H659_tree=null;
        CommonTree SPACE60_tree=null;
        CommonTree SPACE62_tree=null;
        CommonTree H663_tree=null;
        RewriteRuleTokenStream stream_H6=new RewriteRuleTokenStream(adaptor,"token H6");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_title=new RewriteRuleSubtreeStream(adaptor,"rule title");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:5: ( H6 ( SPACE )? title ( SPACE )? H6 -> ^( LEVEL6 title ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:9: H6 ( SPACE )? title ( SPACE )? H6
            {
            H659=(Token)match(input,H6,FOLLOW_H6_in_heading6507);  
            stream_H6.add(H659);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:12: ( SPACE )?
            int alt30=2;
            int LA30_0 = input.LA(1);

            if ( (LA30_0==SPACE) ) {
                alt30=1;
            }
            switch (alt30) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:12: SPACE
                    {
                    SPACE60=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading6509);  
                    stream_SPACE.add(SPACE60);


                    }
                    break;

            }

            pushFollow(FOLLOW_title_in_heading6512);
            title61=title();

            state._fsp--;

            stream_title.add(title61.getTree());
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:25: ( SPACE )?
            int alt31=2;
            int LA31_0 = input.LA(1);

            if ( (LA31_0==SPACE) ) {
                alt31=1;
            }
            switch (alt31) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:25: SPACE
                    {
                    SPACE62=(Token)match(input,SPACE,FOLLOW_SPACE_in_heading6514);  
                    stream_SPACE.add(SPACE62);


                    }
                    break;

            }

            H663=(Token)match(input,H6,FOLLOW_H6_in_heading6517);  
            stream_H6.add(H663);



            // AST REWRITE
            // elements: title
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 47:35: -> ^( LEVEL6 title )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:47:38: ^( LEVEL6 title )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LEVEL6, "LEVEL6"), root_1);

                adaptor.addChild(root_1, stream_title.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "heading6"

    public static class title_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "title"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:48:1: title : ( WORD SPACE )* WORD ;
    public final BestpaperParser.title_return title() throws RecognitionException {
        BestpaperParser.title_return retval = new BestpaperParser.title_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token WORD64=null;
        Token SPACE65=null;
        Token WORD66=null;

        CommonTree WORD64_tree=null;
        CommonTree SPACE65_tree=null;
        CommonTree WORD66_tree=null;

        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:49:5: ( ( WORD SPACE )* WORD )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:49:9: ( WORD SPACE )* WORD
            {
            root_0 = (CommonTree)adaptor.nil();

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:49:9: ( WORD SPACE )*
            loop32:
            do {
                int alt32=2;
                int LA32_0 = input.LA(1);

                if ( (LA32_0==WORD) ) {
                    int LA32_1 = input.LA(2);

                    if ( (LA32_1==SPACE) ) {
                        int LA32_2 = input.LA(3);

                        if ( (LA32_2==WORD) ) {
                            alt32=1;
                        }


                    }


                }


                switch (alt32) {
            	case 1 :
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:49:10: WORD SPACE
            	    {
            	    WORD64=(Token)match(input,WORD,FOLLOW_WORD_in_title550); 
            	    WORD64_tree = (CommonTree)adaptor.create(WORD64);
            	    adaptor.addChild(root_0, WORD64_tree);

            	    SPACE65=(Token)match(input,SPACE,FOLLOW_SPACE_in_title552); 
            	    SPACE65_tree = (CommonTree)adaptor.create(SPACE65);
            	    adaptor.addChild(root_0, SPACE65_tree);


            	    }
            	    break;

            	default :
            	    break loop32;
                }
            } while (true);

            WORD66=(Token)match(input,WORD,FOLLOW_WORD_in_title556); 
            WORD66_tree = (CommonTree)adaptor.create(WORD66);
            adaptor.addChild(root_0, WORD66_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "title"

    public static class content_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "content"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:50:1: content : ( seg ( NEWLINE )+ )* seg -> ^( PARAGRAPH ( seg )+ ) ;
    public final BestpaperParser.content_return content() throws RecognitionException {
        BestpaperParser.content_return retval = new BestpaperParser.content_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NEWLINE68=null;
        BestpaperParser.seg_return seg67 = null;

        BestpaperParser.seg_return seg69 = null;


        CommonTree NEWLINE68_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_seg=new RewriteRuleSubtreeStream(adaptor,"rule seg");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:5: ( ( seg ( NEWLINE )+ )* seg -> ^( PARAGRAPH ( seg )+ ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:9: ( seg ( NEWLINE )+ )* seg
            {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:9: ( seg ( NEWLINE )+ )*
            loop34:
            do {
                int alt34=2;
                alt34 = dfa34.predict(input);
                switch (alt34) {
            	case 1 :
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:10: seg ( NEWLINE )+
            	    {
            	    pushFollow(FOLLOW_seg_in_content573);
            	    seg67=seg();

            	    state._fsp--;

            	    stream_seg.add(seg67.getTree());
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:14: ( NEWLINE )+
            	    int cnt33=0;
            	    loop33:
            	    do {
            	        int alt33=2;
            	        int LA33_0 = input.LA(1);

            	        if ( (LA33_0==NEWLINE) ) {
            	            alt33=1;
            	        }


            	        switch (alt33) {
            	    	case 1 :
            	    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:14: NEWLINE
            	    	    {
            	    	    NEWLINE68=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_content575);  
            	    	    stream_NEWLINE.add(NEWLINE68);


            	    	    }
            	    	    break;

            	    	default :
            	    	    if ( cnt33 >= 1 ) break loop33;
            	                EarlyExitException eee =
            	                    new EarlyExitException(33, input);
            	                throw eee;
            	        }
            	        cnt33++;
            	    } while (true);


            	    }
            	    break;

            	default :
            	    break loop34;
                }
            } while (true);

            pushFollow(FOLLOW_seg_in_content580);
            seg69=seg();

            state._fsp--;

            stream_seg.add(seg69.getTree());


            // AST REWRITE
            // elements: seg
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 51:29: -> ^( PARAGRAPH ( seg )+ )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:51:32: ^( PARAGRAPH ( seg )+ )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(PARAGRAPH, "PARAGRAPH"), root_1);

                if ( !(stream_seg.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_seg.hasNext() ) {
                    adaptor.addChild(root_1, stream_seg.nextTree());

                }
                stream_seg.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "content"

    public static class seg_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "seg"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:52:1: seg : ( row | line );
    public final BestpaperParser.seg_return seg() throws RecognitionException {
        BestpaperParser.seg_return retval = new BestpaperParser.seg_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        BestpaperParser.row_return row70 = null;

        BestpaperParser.line_return line71 = null;



        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:53:2: ( row | line )
            int alt35=2;
            switch ( input.LA(1) ) {
            case SPACE:
                {
                int LA35_1 = input.LA(2);

                if ( (LA35_1==EOF||LA35_1==NEWLINE||LA35_1==WORD) ) {
                    alt35=2;
                }
                else if ( (LA35_1==TABLE_BORD) ) {
                    alt35=1;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 35, 1, input);

                    throw nvae;
                }
                }
                break;
            case TABLE_BORD:
                {
                alt35=1;
                }
                break;
            case WORD:
                {
                alt35=2;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 35, 0, input);

                throw nvae;
            }

            switch (alt35) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:53:4: row
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_row_in_seg600);
                    row70=row();

                    state._fsp--;

                    adaptor.addChild(root_0, row70.getTree());

                    }
                    break;
                case 2 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:53:10: line
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_line_in_seg604);
                    line71=line();

                    state._fsp--;

                    adaptor.addChild(root_0, line71.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "seg"

    public static class line_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "line"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:54:1: line : ( ( SPACE )? ( WORD SPACE )* WORD ( SPACE )? | SPACE );
    public final BestpaperParser.line_return line() throws RecognitionException {
        BestpaperParser.line_return retval = new BestpaperParser.line_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token SPACE72=null;
        Token WORD73=null;
        Token SPACE74=null;
        Token WORD75=null;
        Token SPACE76=null;
        Token SPACE77=null;

        CommonTree SPACE72_tree=null;
        CommonTree WORD73_tree=null;
        CommonTree SPACE74_tree=null;
        CommonTree WORD75_tree=null;
        CommonTree SPACE76_tree=null;
        CommonTree SPACE77_tree=null;

        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:5: ( ( SPACE )? ( WORD SPACE )* WORD ( SPACE )? | SPACE )
            int alt39=2;
            int LA39_0 = input.LA(1);

            if ( (LA39_0==SPACE) ) {
                int LA39_1 = input.LA(2);

                if ( (LA39_1==EOF||LA39_1==NEWLINE||LA39_1==TABLE_BORD) ) {
                    alt39=2;
                }
                else if ( (LA39_1==WORD) ) {
                    alt39=1;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 39, 1, input);

                    throw nvae;
                }
            }
            else if ( (LA39_0==WORD) ) {
                alt39=1;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 39, 0, input);

                throw nvae;
            }
            switch (alt39) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:7: ( SPACE )? ( WORD SPACE )* WORD ( SPACE )?
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:12: ( SPACE )?
                    int alt36=2;
                    int LA36_0 = input.LA(1);

                    if ( (LA36_0==SPACE) ) {
                        alt36=1;
                    }
                    switch (alt36) {
                        case 1 :
                            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:12: SPACE
                            {
                            SPACE72=(Token)match(input,SPACE,FOLLOW_SPACE_in_line617); 

                            }
                            break;

                    }

                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:15: ( WORD SPACE )*
                    loop37:
                    do {
                        int alt37=2;
                        int LA37_0 = input.LA(1);

                        if ( (LA37_0==WORD) ) {
                            int LA37_1 = input.LA(2);

                            if ( (LA37_1==SPACE) ) {
                                int LA37_2 = input.LA(3);

                                if ( (LA37_2==WORD) ) {
                                    alt37=1;
                                }


                            }


                        }


                        switch (alt37) {
                    	case 1 :
                    	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:16: WORD SPACE
                    	    {
                    	    WORD73=(Token)match(input,WORD,FOLLOW_WORD_in_line622); 
                    	    WORD73_tree = (CommonTree)adaptor.create(WORD73);
                    	    adaptor.addChild(root_0, WORD73_tree);

                    	    SPACE74=(Token)match(input,SPACE,FOLLOW_SPACE_in_line624); 
                    	    SPACE74_tree = (CommonTree)adaptor.create(SPACE74);
                    	    adaptor.addChild(root_0, SPACE74_tree);


                    	    }
                    	    break;

                    	default :
                    	    break loop37;
                        }
                    } while (true);

                    WORD75=(Token)match(input,WORD,FOLLOW_WORD_in_line628); 
                    WORD75_tree = (CommonTree)adaptor.create(WORD75);
                    adaptor.addChild(root_0, WORD75_tree);

                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:39: ( SPACE )?
                    int alt38=2;
                    int LA38_0 = input.LA(1);

                    if ( (LA38_0==SPACE) ) {
                        alt38=1;
                    }
                    switch (alt38) {
                        case 1 :
                            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:39: SPACE
                            {
                            SPACE76=(Token)match(input,SPACE,FOLLOW_SPACE_in_line630); 

                            }
                            break;

                    }


                    }
                    break;
                case 2 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:55:44: SPACE
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    SPACE77=(Token)match(input,SPACE,FOLLOW_SPACE_in_line636); 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "line"

    public static class row_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "row"
    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:56:1: row : ( SPACE )? ( TABLE_BORD line )+ TABLE_BORD ( SPACE )? -> ^( ROW ( line )+ ) ;
    public final BestpaperParser.row_return row() throws RecognitionException {
        BestpaperParser.row_return retval = new BestpaperParser.row_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token SPACE78=null;
        Token TABLE_BORD79=null;
        Token TABLE_BORD81=null;
        Token SPACE82=null;
        BestpaperParser.line_return line80 = null;


        CommonTree SPACE78_tree=null;
        CommonTree TABLE_BORD79_tree=null;
        CommonTree TABLE_BORD81_tree=null;
        CommonTree SPACE82_tree=null;
        RewriteRuleTokenStream stream_TABLE_BORD=new RewriteRuleTokenStream(adaptor,"token TABLE_BORD");
        RewriteRuleTokenStream stream_SPACE=new RewriteRuleTokenStream(adaptor,"token SPACE");
        RewriteRuleSubtreeStream stream_line=new RewriteRuleSubtreeStream(adaptor,"rule line");
        try {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:2: ( ( SPACE )? ( TABLE_BORD line )+ TABLE_BORD ( SPACE )? -> ^( ROW ( line )+ ) )
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:4: ( SPACE )? ( TABLE_BORD line )+ TABLE_BORD ( SPACE )?
            {
            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:4: ( SPACE )?
            int alt40=2;
            int LA40_0 = input.LA(1);

            if ( (LA40_0==SPACE) ) {
                alt40=1;
            }
            switch (alt40) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:4: SPACE
                    {
                    SPACE78=(Token)match(input,SPACE,FOLLOW_SPACE_in_row645);  
                    stream_SPACE.add(SPACE78);


                    }
                    break;

            }

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:11: ( TABLE_BORD line )+
            int cnt41=0;
            loop41:
            do {
                int alt41=2;
                int LA41_0 = input.LA(1);

                if ( (LA41_0==TABLE_BORD) ) {
                    int LA41_1 = input.LA(2);

                    if ( (LA41_1==SPACE) ) {
                        int LA41_2 = input.LA(3);

                        if ( ((LA41_2>=WORD && LA41_2<=TABLE_BORD)) ) {
                            alt41=1;
                        }


                    }
                    else if ( (LA41_1==WORD) ) {
                        alt41=1;
                    }


                }


                switch (alt41) {
            	case 1 :
            	    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:12: TABLE_BORD line
            	    {
            	    TABLE_BORD79=(Token)match(input,TABLE_BORD,FOLLOW_TABLE_BORD_in_row649);  
            	    stream_TABLE_BORD.add(TABLE_BORD79);

            	    pushFollow(FOLLOW_line_in_row651);
            	    line80=line();

            	    state._fsp--;

            	    stream_line.add(line80.getTree());

            	    }
            	    break;

            	default :
            	    if ( cnt41 >= 1 ) break loop41;
                        EarlyExitException eee =
                            new EarlyExitException(41, input);
                        throw eee;
                }
                cnt41++;
            } while (true);

            TABLE_BORD81=(Token)match(input,TABLE_BORD,FOLLOW_TABLE_BORD_in_row655);  
            stream_TABLE_BORD.add(TABLE_BORD81);

            // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:41: ( SPACE )?
            int alt42=2;
            int LA42_0 = input.LA(1);

            if ( (LA42_0==SPACE) ) {
                alt42=1;
            }
            switch (alt42) {
                case 1 :
                    // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:41: SPACE
                    {
                    SPACE82=(Token)match(input,SPACE,FOLLOW_SPACE_in_row657);  
                    stream_SPACE.add(SPACE82);


                    }
                    break;

            }



            // AST REWRITE
            // elements: line
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 57:48: -> ^( ROW ( line )+ )
            {
                // /Users/alin/Documents/workspace/trunk/bestpaper/src/antlr/Bestpaper.g:57:51: ^( ROW ( line )+ )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(ROW, "ROW"), root_1);

                if ( !(stream_line.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_line.hasNext() ) {
                    adaptor.addChild(root_1, stream_line.nextTree());

                }
                stream_line.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "row"

    // Delegated rules


    protected DFA2 dfa2 = new DFA2(this);
    protected DFA10 dfa10 = new DFA10(this);
    protected DFA8 dfa8 = new DFA8(this);
    protected DFA16 dfa16 = new DFA16(this);
    protected DFA34 dfa34 = new DFA34(this);
    static final String DFA2_eotS =
        "\100\uffff";
    static final String DFA2_eofS =
        "\11\uffff\1\23\1\uffff\1\23\6\uffff\1\23\3\uffff\1\23\14\uffff\1"+
        "\23\1\uffff\1\23\2\uffff\1\23\1\uffff\1\23\1\uffff\1\23\1\uffff"+
        "\1\23\1\uffff\1\23\1\uffff\5\23\1\uffff\2\23\2\uffff\2\23\1\uffff"+
        "\1\23";
    static final String DFA2_minS =
        "\1\21\1\22\1\21\1\31\1\21\1\22\4\20\1\21\1\20\6\21\1\20\1\uffff"+
        "\1\31\1\21\1\20\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21"+
        "\1\31\1\21\1\20\1\uffff\1\20\1\31\1\23\1\20\1\24\1\20\1\25\1\20"+
        "\1\26\1\20\1\27\1\20\1\30\5\20\1\21\2\20\1\31\1\21\2\20\1\31\1\20";
    static final String DFA2_maxS =
        "\2\22\2\31\1\22\1\31\1\21\1\20\2\32\1\31\1\21\6\31\1\32\1\uffff"+
        "\2\32\2\31\1\23\1\31\1\24\1\31\1\25\1\31\1\26\1\31\1\27\1\31\1\30"+
        "\1\32\1\uffff\1\31\1\32\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21"+
        "\1\31\1\21\1\31\1\21\1\32\1\20\2\32\1\31\1\21\3\32\2\31\2\32";
    static final String DFA2_acceptS =
        "\23\uffff\1\2\20\uffff\1\1\33\uffff";
    static final String DFA2_specialS =
        "\100\uffff}>";
    static final String[] DFA2_transitionS = {
            "\1\1\1\2",
            "\1\2",
            "\1\3\7\uffff\1\4",
            "\1\4",
            "\1\5\1\6",
            "\1\6\6\uffff\1\4",
            "\1\10\1\7",
            "\1\10",
            "\1\10\1\11\1\uffff\1\14\1\15\1\16\1\17\1\20\1\21\1\13\1\12",
            "\1\22\2\uffff\1\14\1\15\1\16\1\17\1\20\1\21\1\13\1\12",
            "\1\24\7\uffff\1\25",
            "\1\22\1\26",
            "\1\27\7\uffff\1\30",
            "\1\31\7\uffff\1\32",
            "\1\33\7\uffff\1\34",
            "\1\35\7\uffff\1\36",
            "\1\37\7\uffff\1\40",
            "\1\41\7\uffff\1\42",
            "\1\22\1\43\1\44\1\14\1\15\1\16\1\17\1\20\1\21\1\13\1\12",
            "",
            "\1\25\1\45",
            "\1\46\10\uffff\1\45",
            "\1\22\10\uffff\1\13",
            "\1\30",
            "\1\47\1\uffff\1\50",
            "\1\32",
            "\1\51\2\uffff\1\52",
            "\1\34",
            "\1\53\3\uffff\1\54",
            "\1\36",
            "\1\55\4\uffff\1\56",
            "\1\40",
            "\1\57\5\uffff\1\60",
            "\1\42",
            "\1\61\6\uffff\1\62",
            "\1\22\1\uffff\1\44\1\14\1\15\1\16\1\17\1\20\1\21\1\13\1\12",
            "",
            "\1\22\1\63\7\uffff\1\25",
            "\1\25\1\45",
            "\1\50\5\uffff\1\30",
            "\1\65\1\64",
            "\1\52\4\uffff\1\32",
            "\1\65\1\64",
            "\1\54\3\uffff\1\34",
            "\1\65\1\64",
            "\1\56\2\uffff\1\36",
            "\1\65\1\64",
            "\1\60\1\uffff\1\40",
            "\1\65\1\64",
            "\1\62\1\42",
            "\1\65\1\64",
            "\1\22\10\uffff\1\25\1\45",
            "\1\65",
            "\1\65\1\66\1\44\1\14\1\15\1\16\1\17\1\20\1\21\1\70\1\67",
            "\1\71\1\uffff\1\44\1\14\1\15\1\16\1\17\1\20\1\21\1\70\1\67",
            "\1\72\7\uffff\1\73",
            "\1\71\1\74",
            "\1\71\1\66\1\44\1\14\1\15\1\16\1\17\1\20\1\21\1\70\1\67",
            "\1\73\1\75",
            "\1\76\10\uffff\1\75",
            "\1\71\10\uffff\1\70",
            "\1\71\1\77\7\uffff\1\73",
            "\1\73\1\75",
            "\1\71\10\uffff\1\73\1\75"
    };

    static final short[] DFA2_eot = DFA.unpackEncodedString(DFA2_eotS);
    static final short[] DFA2_eof = DFA.unpackEncodedString(DFA2_eofS);
    static final char[] DFA2_min = DFA.unpackEncodedStringToUnsignedChars(DFA2_minS);
    static final char[] DFA2_max = DFA.unpackEncodedStringToUnsignedChars(DFA2_maxS);
    static final short[] DFA2_accept = DFA.unpackEncodedString(DFA2_acceptS);
    static final short[] DFA2_special = DFA.unpackEncodedString(DFA2_specialS);
    static final short[][] DFA2_transition;

    static {
        int numStates = DFA2_transitionS.length;
        DFA2_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA2_transition[i] = DFA.unpackEncodedString(DFA2_transitionS[i]);
        }
    }

    class DFA2 extends DFA {

        public DFA2(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 2;
            this.eot = DFA2_eot;
            this.eof = DFA2_eof;
            this.min = DFA2_min;
            this.max = DFA2_max;
            this.accept = DFA2_accept;
            this.special = DFA2_special;
            this.transition = DFA2_transition;
        }
        public String getDescription() {
            return "()* loopback of 24:4: ( chapter ( NEWLINE )+ )*";
        }
    }
    static final String DFA10_eotS =
        "\26\uffff";
    static final String DFA10_eofS =
        "\11\uffff\1\16\1\uffff\1\16\1\uffff\1\16\3\uffff\3\16\1\uffff\1"+
        "\16";
    static final String DFA10_minS =
        "\1\21\1\22\1\21\1\31\1\21\1\22\4\20\1\21\1\20\1\uffff\1\20\1\uffff"+
        "\1\31\1\21\3\20\1\31\1\20";
    static final String DFA10_maxS =
        "\2\22\2\31\1\22\1\31\1\21\1\20\2\32\1\31\1\21\1\uffff\1\32\1\uffff"+
        "\2\32\1\31\1\32\1\31\2\32";
    static final String DFA10_acceptS =
        "\14\uffff\1\1\1\uffff\1\2\7\uffff";
    static final String DFA10_specialS =
        "\26\uffff}>";
    static final String[] DFA10_transitionS = {
            "\1\1\1\2",
            "\1\2",
            "\1\3\7\uffff\1\4",
            "\1\4",
            "\1\5\1\6",
            "\1\6\6\uffff\1\4",
            "\1\10\1\7",
            "\1\10",
            "\1\10\1\11\1\uffff\6\14\1\13\1\12",
            "\1\15\2\uffff\6\14\1\13\1\12",
            "\1\17\7\uffff\1\20",
            "\1\15\1\21",
            "",
            "\1\15\1\22\1\16\6\14\1\13\1\12",
            "",
            "\1\20\1\23",
            "\1\24\10\uffff\1\23",
            "\1\15\10\uffff\1\13",
            "\1\15\1\uffff\1\16\6\14\1\13\1\12",
            "\1\15\1\25\7\uffff\1\20",
            "\1\20\1\23",
            "\1\15\10\uffff\1\20\1\23"
    };

    static final short[] DFA10_eot = DFA.unpackEncodedString(DFA10_eotS);
    static final short[] DFA10_eof = DFA.unpackEncodedString(DFA10_eofS);
    static final char[] DFA10_min = DFA.unpackEncodedStringToUnsignedChars(DFA10_minS);
    static final char[] DFA10_max = DFA.unpackEncodedStringToUnsignedChars(DFA10_maxS);
    static final short[] DFA10_accept = DFA.unpackEncodedString(DFA10_acceptS);
    static final short[] DFA10_special = DFA.unpackEncodedString(DFA10_specialS);
    static final short[][] DFA10_transition;

    static {
        int numStates = DFA10_transitionS.length;
        DFA10_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA10_transition[i] = DFA.unpackEncodedString(DFA10_transitionS[i]);
        }
    }

    class DFA10 extends DFA {

        public DFA10(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 10;
            this.eot = DFA10_eot;
            this.eof = DFA10_eof;
            this.min = DFA10_min;
            this.max = DFA10_max;
            this.accept = DFA10_accept;
            this.special = DFA10_special;
            this.transition = DFA10_transition;
        }
        public String getDescription() {
            return "25:1: chapter : ( chapter_heading ( NEWLINE )+ ( content ( NEWLINE )+ )? ( section ( NEWLINE )+ )* section -> ^( CHAPTER chapter_heading ( content )? ( section )+ ) | chapter_heading ( NEWLINE )+ content -> ^( CHAPTER chapter_heading content ) );";
        }
    }
    static final String DFA8_eotS =
        "\56\uffff";
    static final String DFA8_eofS =
        "\25\uffff\1\42\1\uffff\1\42\1\uffff\1\42\1\uffff\1\42\1\uffff\1"+
        "\42\1\uffff\3\42\1\uffff\1\42\1\uffff\1\42\1\uffff\1\42\2\uffff"+
        "\2\42\1\uffff\1\42";
    static final String DFA8_minS =
        "\1\21\1\23\6\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21"+
        "\1\31\1\21\1\23\1\20\1\24\1\20\1\25\1\20\1\26\1\20\1\27\1\20\1\30"+
        "\3\20\1\uffff\1\20\1\21\1\20\1\uffff\1\20\1\31\1\21\2\20\1\31\1"+
        "\20";
    static final String DFA8_maxS =
        "\2\30\7\31\1\23\1\31\1\24\1\31\1\25\1\31\1\26\1\31\1\27\1\31\1\30"+
        "\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\20"+
        "\1\32\1\uffff\1\32\1\31\1\21\1\uffff\3\32\2\31\2\32";
    static final String DFA8_acceptS =
        "\42\uffff\1\2\3\uffff\1\1\7\uffff";
    static final String DFA8_specialS =
        "\56\uffff}>";
    static final String[] DFA8_transitionS = {
            "\1\1\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7",
            "\1\2\1\3\1\4\1\5\1\6\1\7",
            "\1\10\7\uffff\1\11",
            "\1\12\7\uffff\1\13",
            "\1\14\7\uffff\1\15",
            "\1\16\7\uffff\1\17",
            "\1\20\7\uffff\1\21",
            "\1\22\7\uffff\1\23",
            "\1\11",
            "\1\24\1\uffff\1\25",
            "\1\13",
            "\1\26\2\uffff\1\27",
            "\1\15",
            "\1\30\3\uffff\1\31",
            "\1\17",
            "\1\32\4\uffff\1\33",
            "\1\21",
            "\1\34\5\uffff\1\35",
            "\1\23",
            "\1\36\6\uffff\1\37",
            "\1\25\5\uffff\1\11",
            "\1\41\1\40",
            "\1\27\4\uffff\1\13",
            "\1\41\1\40",
            "\1\31\3\uffff\1\15",
            "\1\41\1\40",
            "\1\33\2\uffff\1\17",
            "\1\41\1\40",
            "\1\35\1\uffff\1\21",
            "\1\41\1\40",
            "\1\37\1\23",
            "\1\41\1\40",
            "\1\41",
            "\1\41\1\43\1\42\6\46\1\45\1\44",
            "",
            "\1\47\1\uffff\1\42\6\46\1\45\1\44",
            "\1\50\7\uffff\1\51",
            "\1\47\1\52",
            "",
            "\1\47\1\43\1\42\6\46\1\45\1\44",
            "\1\51\1\53",
            "\1\54\10\uffff\1\53",
            "\1\47\10\uffff\1\45",
            "\1\47\1\55\7\uffff\1\51",
            "\1\51\1\53",
            "\1\47\10\uffff\1\51\1\53"
    };

    static final short[] DFA8_eot = DFA.unpackEncodedString(DFA8_eotS);
    static final short[] DFA8_eof = DFA.unpackEncodedString(DFA8_eofS);
    static final char[] DFA8_min = DFA.unpackEncodedStringToUnsignedChars(DFA8_minS);
    static final char[] DFA8_max = DFA.unpackEncodedStringToUnsignedChars(DFA8_maxS);
    static final short[] DFA8_accept = DFA.unpackEncodedString(DFA8_acceptS);
    static final short[] DFA8_special = DFA.unpackEncodedString(DFA8_specialS);
    static final short[][] DFA8_transition;

    static {
        int numStates = DFA8_transitionS.length;
        DFA8_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA8_transition[i] = DFA.unpackEncodedString(DFA8_transitionS[i]);
        }
    }

    class DFA8 extends DFA {

        public DFA8(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 8;
            this.eot = DFA8_eot;
            this.eof = DFA8_eof;
            this.min = DFA8_min;
            this.max = DFA8_max;
            this.accept = DFA8_accept;
            this.special = DFA8_special;
            this.transition = DFA8_transition;
        }
        public String getDescription() {
            return "()* loopback of 26:49: ( section ( NEWLINE )+ )*";
        }
    }
    static final String DFA16_eotS =
        "\45\uffff";
    static final String DFA16_eofS =
        "\25\uffff\1\42\1\uffff\1\42\1\uffff\1\42\1\uffff\1\42\1\uffff\1"+
        "\42\1\uffff\3\42\1\uffff\1\44\1\uffff";
    static final String DFA16_minS =
        "\1\21\1\23\6\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21"+
        "\1\31\1\21\1\23\1\20\1\24\1\20\1\25\1\20\1\26\1\20\1\27\1\20\1\30"+
        "\3\20\1\uffff\1\20\1\uffff";
    static final String DFA16_maxS =
        "\2\30\7\31\1\23\1\31\1\24\1\31\1\25\1\31\1\26\1\31\1\27\1\31\1\30"+
        "\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\31\1\21\1\20"+
        "\1\32\1\uffff\1\32\1\uffff";
    static final String DFA16_acceptS =
        "\42\uffff\1\2\1\uffff\1\1";
    static final String DFA16_specialS =
        "\45\uffff}>";
    static final String[] DFA16_transitionS = {
            "\1\1\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7",
            "\1\2\1\3\1\4\1\5\1\6\1\7",
            "\1\10\7\uffff\1\11",
            "\1\12\7\uffff\1\13",
            "\1\14\7\uffff\1\15",
            "\1\16\7\uffff\1\17",
            "\1\20\7\uffff\1\21",
            "\1\22\7\uffff\1\23",
            "\1\11",
            "\1\24\1\uffff\1\25",
            "\1\13",
            "\1\26\2\uffff\1\27",
            "\1\15",
            "\1\30\3\uffff\1\31",
            "\1\17",
            "\1\32\4\uffff\1\33",
            "\1\21",
            "\1\34\5\uffff\1\35",
            "\1\23",
            "\1\36\6\uffff\1\37",
            "\1\25\5\uffff\1\11",
            "\1\41\1\40",
            "\1\27\4\uffff\1\13",
            "\1\41\1\40",
            "\1\31\3\uffff\1\15",
            "\1\41\1\40",
            "\1\33\2\uffff\1\17",
            "\1\41\1\40",
            "\1\35\1\uffff\1\21",
            "\1\41\1\40",
            "\1\37\1\23",
            "\1\41\1\40",
            "\1\41",
            "\1\41\1\43\7\42\2\44",
            "",
            "\1\44\1\uffff\7\42\2\44",
            ""
    };

    static final short[] DFA16_eot = DFA.unpackEncodedString(DFA16_eotS);
    static final short[] DFA16_eof = DFA.unpackEncodedString(DFA16_eofS);
    static final char[] DFA16_min = DFA.unpackEncodedStringToUnsignedChars(DFA16_minS);
    static final char[] DFA16_max = DFA.unpackEncodedStringToUnsignedChars(DFA16_maxS);
    static final short[] DFA16_accept = DFA.unpackEncodedString(DFA16_acceptS);
    static final short[] DFA16_special = DFA.unpackEncodedString(DFA16_specialS);
    static final short[][] DFA16_transition;

    static {
        int numStates = DFA16_transitionS.length;
        DFA16_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA16_transition[i] = DFA.unpackEncodedString(DFA16_transitionS[i]);
        }
    }

    class DFA16 extends DFA {

        public DFA16(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 16;
            this.eot = DFA16_eot;
            this.eof = DFA16_eof;
            this.min = DFA16_min;
            this.max = DFA16_max;
            this.accept = DFA16_accept;
            this.special = DFA16_special;
            this.transition = DFA16_transition;
        }
        public String getDescription() {
            return "31:1: section : ( heading ( NEWLINE )+ content -> ^( SECTION heading content ) | heading -> ^( SECTION heading ) );";
        }
    }
    static final String DFA34_eotS =
        "\16\uffff";
    static final String DFA34_eofS =
        "\1\uffff\1\5\1\uffff\2\5\3\uffff\1\5\1\12\1\uffff\1\5\1\uffff\1"+
        "\5";
    static final String DFA34_minS =
        "\1\21\1\20\1\21\2\20\1\uffff\1\31\1\21\2\20\1\uffff\1\20\1\31\1"+
        "\20";
    static final String DFA34_maxS =
        "\2\32\1\31\1\21\1\32\1\uffff\2\32\1\31\1\32\1\uffff\1\31\2\32";
    static final String DFA34_acceptS =
        "\5\uffff\1\2\4\uffff\1\1\3\uffff";
    static final String DFA34_specialS =
        "\16\uffff}>";
    static final String[] DFA34_transitionS = {
            "\1\1\7\uffff\1\3\1\2",
            "\1\4\10\uffff\1\3\1\2",
            "\1\6\7\uffff\1\7",
            "\1\4\1\10",
            "\1\4\1\11\7\5\2\12",
            "",
            "\1\7\1\13",
            "\1\14\10\uffff\1\13",
            "\1\4\10\uffff\1\3",
            "\1\12\1\uffff\7\5\2\12",
            "",
            "\1\4\1\15\7\uffff\1\7",
            "\1\7\1\13",
            "\1\4\10\uffff\1\7\1\13"
    };

    static final short[] DFA34_eot = DFA.unpackEncodedString(DFA34_eotS);
    static final short[] DFA34_eof = DFA.unpackEncodedString(DFA34_eofS);
    static final char[] DFA34_min = DFA.unpackEncodedStringToUnsignedChars(DFA34_minS);
    static final char[] DFA34_max = DFA.unpackEncodedStringToUnsignedChars(DFA34_maxS);
    static final short[] DFA34_accept = DFA.unpackEncodedString(DFA34_acceptS);
    static final short[] DFA34_special = DFA.unpackEncodedString(DFA34_specialS);
    static final short[][] DFA34_transition;

    static {
        int numStates = DFA34_transitionS.length;
        DFA34_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA34_transition[i] = DFA.unpackEncodedString(DFA34_transitionS[i]);
        }
    }

    class DFA34 extends DFA {

        public DFA34(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 34;
            this.eot = DFA34_eot;
            this.eof = DFA34_eof;
            this.min = DFA34_min;
            this.max = DFA34_max;
            this.accept = DFA34_accept;
            this.special = DFA34_special;
            this.transition = DFA34_transition;
        }
        public String getDescription() {
            return "()* loopback of 51:9: ( seg ( NEWLINE )+ )*";
        }
    }
 

    public static final BitSet FOLLOW_chapter_in_book99 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_book101 = new BitSet(new long[]{0x0000000000070000L});
    public static final BitSet FOLLOW_chapter_in_book106 = new BitSet(new long[]{0x0000000000010002L});
    public static final BitSet FOLLOW_NEWLINE_in_book108 = new BitSet(new long[]{0x0000000000010002L});
    public static final BitSet FOLLOW_chapter_heading_in_chapter129 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_chapter131 = new BitSet(new long[]{0x0000000007FB0000L});
    public static final BitSet FOLLOW_content_in_chapter135 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_chapter137 = new BitSet(new long[]{0x0000000001FB0000L});
    public static final BitSet FOLLOW_section_in_chapter143 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_chapter145 = new BitSet(new long[]{0x0000000001FB0000L});
    public static final BitSet FOLLOW_section_in_chapter150 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_chapter_heading_in_chapter169 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_chapter171 = new BitSet(new long[]{0x0000000006030000L});
    public static final BitSet FOLLOW_content_in_chapter174 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SPACE_in_chapter_heading199 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_CH_in_chapter_heading202 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_chapter_heading204 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_chapter_heading207 = new BitSet(new long[]{0x0000000000060000L});
    public static final BitSet FOLLOW_SPACE_in_chapter_heading209 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_CH_in_chapter_heading212 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_SPACE_in_chapter_heading214 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_heading_in_section235 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_section237 = new BitSet(new long[]{0x0000000006030000L});
    public static final BitSet FOLLOW_content_in_section240 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_heading_in_section255 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SPACE_in_heading280 = new BitSet(new long[]{0x0000000001FA0000L});
    public static final BitSet FOLLOW_heading1_in_heading285 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_heading2_in_heading289 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_heading3_in_heading293 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_heading4_in_heading297 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_heading5_in_heading301 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_heading6_in_heading305 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_SPACE_in_heading308 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H1_in_heading1332 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading1334 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading1337 = new BitSet(new long[]{0x00000000000A0000L});
    public static final BitSet FOLLOW_SPACE_in_heading1339 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_H1_in_heading1342 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H2_in_heading2367 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading2369 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading2372 = new BitSet(new long[]{0x0000000000120000L});
    public static final BitSet FOLLOW_SPACE_in_heading2374 = new BitSet(new long[]{0x0000000000100000L});
    public static final BitSet FOLLOW_H2_in_heading2377 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H3_in_heading3402 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading3404 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading3407 = new BitSet(new long[]{0x0000000000220000L});
    public static final BitSet FOLLOW_SPACE_in_heading3409 = new BitSet(new long[]{0x0000000000200000L});
    public static final BitSet FOLLOW_H3_in_heading3412 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H4_in_heading4437 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading4439 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading4442 = new BitSet(new long[]{0x0000000000420000L});
    public static final BitSet FOLLOW_SPACE_in_heading4444 = new BitSet(new long[]{0x0000000000400000L});
    public static final BitSet FOLLOW_H4_in_heading4447 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H5_in_heading5472 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading5474 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading5477 = new BitSet(new long[]{0x0000000000820000L});
    public static final BitSet FOLLOW_SPACE_in_heading5479 = new BitSet(new long[]{0x0000000000800000L});
    public static final BitSet FOLLOW_H5_in_heading5482 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_H6_in_heading6507 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_SPACE_in_heading6509 = new BitSet(new long[]{0x0000000002020000L});
    public static final BitSet FOLLOW_title_in_heading6512 = new BitSet(new long[]{0x0000000001020000L});
    public static final BitSet FOLLOW_SPACE_in_heading6514 = new BitSet(new long[]{0x0000000001000000L});
    public static final BitSet FOLLOW_H6_in_heading6517 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_WORD_in_title550 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_SPACE_in_title552 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_WORD_in_title556 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_seg_in_content573 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_NEWLINE_in_content575 = new BitSet(new long[]{0x0000000006030000L});
    public static final BitSet FOLLOW_seg_in_content580 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_row_in_seg600 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_line_in_seg604 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SPACE_in_line617 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_WORD_in_line622 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_SPACE_in_line624 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_WORD_in_line628 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_SPACE_in_line630 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SPACE_in_line636 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SPACE_in_row645 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_TABLE_BORD_in_row649 = new BitSet(new long[]{0x0000000006020000L});
    public static final BitSet FOLLOW_line_in_row651 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_TABLE_BORD_in_row655 = new BitSet(new long[]{0x0000000000020002L});
    public static final BitSet FOLLOW_SPACE_in_row657 = new BitSet(new long[]{0x0000000000000002L});

}